<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LANGUAGE Trustworthy       #-}</span><span>
</span><span id="line-2"></span><span class="hs-pragma">{-# LANGUAGE NoImplicitPrelude #-}</span><span>
</span><span id="line-3"></span><span class="hs-pragma">{-# LANGUAGE CPP               #-}</span><span>
</span><span id="line-4"></span><span>
</span><span id="line-5"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-6"></span><span class="hs-comment">-- |</span><span>
</span><span id="line-7"></span><span class="hs-comment">-- Module      :  GHC.IO.SubSystem</span><span>
</span><span id="line-8"></span><span class="hs-comment">-- Copyright   :  (c) The University of Glasgow, 2017</span><span>
</span><span id="line-9"></span><span class="hs-comment">-- License     :  see libraries/base/LICENSE</span><span>
</span><span id="line-10"></span><span class="hs-comment">--</span><span>
</span><span id="line-11"></span><span class="hs-comment">-- Maintainer  :  libraries@haskell.org</span><span>
</span><span id="line-12"></span><span class="hs-comment">-- Stability   :  internal</span><span>
</span><span id="line-13"></span><span class="hs-comment">-- Portability :  non-portable</span><span>
</span><span id="line-14"></span><span class="hs-comment">--</span><span>
</span><span id="line-15"></span><span class="hs-comment">-- The SubSystem control interface.  These methods can be used to disambiguate</span><span>
</span><span id="line-16"></span><span class="hs-comment">-- between the two operations.</span><span>
</span><span id="line-17"></span><span class="hs-comment">--</span><span>
</span><span id="line-18"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-19"></span><span>
</span><span id="line-20"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">GHC.IO.SubSystem</span><span> </span><span class="hs-special">(</span><span>
</span><span id="line-21"></span><span>  </span><span class="annot"><a href="GHC.IO.SubSystem.html#withIoSubSystem"><span class="hs-identifier">withIoSubSystem</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-22"></span><span>  </span><span class="annot"><a href="GHC.IO.SubSystem.html#withIoSubSystem%27"><span class="hs-identifier">withIoSubSystem'</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-23"></span><span>  </span><span class="annot"><a href="GHC.IO.SubSystem.html#whenIoSubSystem"><span class="hs-identifier">whenIoSubSystem</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-24"></span><span>  </span><span class="annot"><a href="GHC.IO.SubSystem.html#ioSubSystem"><span class="hs-identifier">ioSubSystem</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-25"></span><span>  </span><span class="annot"><a href="GHC.RTS.Flags.html#IoSubSystem"><span class="hs-identifier">IoSubSystem</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span>
</span><span id="line-26"></span><span>  </span><span class="annot"><a href="GHC.IO.SubSystem.html#conditional"><span class="hs-identifier">conditional</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-27"></span><span>  </span><span class="annot"><a href="GHC.IO.SubSystem.html#%3C%21%3E"><span class="hs-operator">(&lt;!&gt;)</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-28"></span><span>  </span><span class="annot"><a href="GHC.IO.SubSystem.html#isWindowsNativeIO"><span class="hs-identifier">isWindowsNativeIO</span></a></span><span>
</span><span id="line-29"></span><span> </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-30"></span><span>
</span><span id="line-31"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Base.html"><span class="hs-identifier">GHC.Base</span></a></span><span>
</span><span id="line-32"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.RTS.Flags.html"><span class="hs-identifier">GHC.RTS.Flags</span></a></span><span class="hs-cpp">

#if defined(mingw32_HOST_OS)
</span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.IO.Unsafe.html"><span class="hs-identifier">GHC.IO.Unsafe</span></a></span><span class="hs-cpp">
#endif
</span><span>
</span><span id="line-38"></span><span class="hs-keyword">infixl</span><span> </span><span class="hs-number">7</span><span> </span><span class="annot"><a href="GHC.IO.SubSystem.html#%3C%21%3E"><span class="hs-operator hs-type">&lt;!&gt;</span></a></span><span>
</span><span id="line-39"></span><span>
</span><span id="line-40"></span><span class="hs-comment">-- | Conditionally execute an action depending on the configured I/O subsystem.</span><span>
</span><span id="line-41"></span><span class="hs-comment">-- On POSIX systems always execute the first action.</span><span>
</span><span id="line-42"></span><span class="hs-comment">-- On windows execute the second action if WINIO as active, otherwise fall back to</span><span>
</span><span id="line-43"></span><span class="hs-comment">-- the first action.</span><span>
</span><span id="line-44"></span><span id="local-6989586621679540238"><span class="annot"><a href="GHC.IO.SubSystem.html#conditional"><span class="hs-identifier hs-type">conditional</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="#local-6989586621679540238"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679540238"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679540238"><span class="hs-identifier hs-type">a</span></a></span></span><span class="hs-cpp">
#if defined(mingw32_HOST_OS)
</span><span id="conditional"><span class="annot"><span class="annottext">conditional :: forall a. a -&gt; a -&gt; a
</span><a href="GHC.IO.SubSystem.html#conditional"><span class="hs-identifier hs-var hs-var">conditional</span></a></span></span><span> </span><span id="local-6989586621679540217"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679540217"><span class="hs-identifier hs-var">posix</span></a></span></span><span> </span><span id="local-6989586621679540216"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679540216"><span class="hs-identifier hs-var">windows</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-47"></span><span>  </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">IoSubSystem
</span><a href="GHC.IO.SubSystem.html#ioSubSystem"><span class="hs-identifier hs-var">ioSubSystem</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-48"></span><span>    </span><span class="annot"><span class="annottext">IoSubSystem
</span><a href="GHC.RTS.Flags.html#IoPOSIX"><span class="hs-identifier hs-var">IoPOSIX</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679540217"><span class="hs-identifier hs-var">posix</span></a></span><span>
</span><span id="line-49"></span><span>    </span><span class="annot"><span class="annottext">IoSubSystem
</span><a href="GHC.RTS.Flags.html#IoNative"><span class="hs-identifier hs-var">IoNative</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679540216"><span class="hs-identifier hs-var">windows</span></a></span><span class="hs-cpp">
#else
</span><span class="hs-identifier">conditional</span><span> </span><span class="hs-identifier">posix</span><span> </span><span class="hs-identifier">_</span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">posix</span><span class="hs-cpp">
#endif
</span><span>
</span><span id="line-54"></span><span class="hs-comment">-- | Infix version of `conditional`.</span><span>
</span><span id="line-55"></span><span class="hs-comment">-- posix &lt;!&gt; windows == conditional posix windows</span><span>
</span><span id="line-56"></span><span id="local-6989586621679540213"><span class="annot"><a href="GHC.IO.SubSystem.html#%3C%21%3E"><span class="hs-operator hs-type">(&lt;!&gt;)</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="#local-6989586621679540213"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679540213"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679540213"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-57"></span><span id="%3C%21%3E"><span class="annot"><span class="annottext">&lt;!&gt; :: forall a. a -&gt; a -&gt; a
</span><a href="GHC.IO.SubSystem.html#%3C%21%3E"><span class="hs-operator hs-var hs-var">(&lt;!&gt;)</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">a -&gt; a -&gt; a
forall a. a -&gt; a -&gt; a
</span><a href="GHC.IO.SubSystem.html#conditional"><span class="hs-identifier hs-var">conditional</span></a></span><span>
</span><span id="line-58"></span><span>
</span><span id="line-59"></span><span class="annot"><a href="GHC.IO.SubSystem.html#isWindowsNativeIO"><span class="hs-identifier hs-type">isWindowsNativeIO</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Bool"><span class="hs-identifier hs-type">Bool</span></a></span><span>
</span><span id="line-60"></span><span id="isWindowsNativeIO"><span class="annot"><span class="annottext">isWindowsNativeIO :: Bool
</span><a href="GHC.IO.SubSystem.html#isWindowsNativeIO"><span class="hs-identifier hs-var hs-var">isWindowsNativeIO</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../ghc-prim/src/GHC.Types.html#False"><span class="hs-identifier hs-var">False</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
forall a. a -&gt; a -&gt; a
</span><a href="GHC.IO.SubSystem.html#%3C%21%3E"><span class="hs-operator hs-var">&lt;!&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../ghc-prim/src/GHC.Types.html#True"><span class="hs-identifier hs-var">True</span></a></span><span>
</span><span id="line-61"></span><span>
</span><span id="line-62"></span><span class="annot"><a href="GHC.IO.SubSystem.html#ioSubSystem"><span class="hs-identifier hs-type">ioSubSystem</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.RTS.Flags.html#IoSubSystem"><span class="hs-identifier hs-type">IoSubSystem</span></a></span><span class="hs-cpp">
#if defined(mingw32_HOST_OS)
</span><span class="hs-pragma">{-# NOINLINE</span><span> </span><span class="annot"><a href="GHC.IO.SubSystem.html#ioSubSystem"><span class="hs-pragma hs-type">ioSubSystem</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-65"></span><span id="ioSubSystem"><span class="annot"><span class="annottext">ioSubSystem :: IoSubSystem
</span><a href="GHC.IO.SubSystem.html#ioSubSystem"><span class="hs-identifier hs-var hs-var">ioSubSystem</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IO IoSubSystem -&gt; IoSubSystem
forall a. IO a -&gt; a
</span><a href="GHC.IO.Unsafe.html#unsafeDupablePerformIO"><span class="hs-identifier hs-var">unsafeDupablePerformIO</span></a></span><span> </span><span class="annot"><span class="annottext">IO IoSubSystem
</span><a href="GHC.RTS.Flags.html#getIoManagerFlag"><span class="hs-identifier hs-var">getIoManagerFlag</span></a></span><span class="hs-cpp">
#else
</span><span class="hs-identifier">ioSubSystem</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">IoPOSIX</span><span class="hs-cpp">
#endif
</span><span>
</span><span id="line-70"></span><span id="local-6989586621679540234"><span class="annot"><a href="GHC.IO.SubSystem.html#withIoSubSystem"><span class="hs-identifier hs-type">withIoSubSystem</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.RTS.Flags.html#IoSubSystem"><span class="hs-identifier hs-type">IoSubSystem</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679540234"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679540234"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-71"></span><span id="withIoSubSystem"><span class="annot"><span class="annottext">withIoSubSystem :: forall a. (IoSubSystem -&gt; IO a) -&gt; IO a
</span><a href="GHC.IO.SubSystem.html#withIoSubSystem"><span class="hs-identifier hs-var hs-var">withIoSubSystem</span></a></span></span><span> </span><span id="local-6989586621679540210"><span class="annot"><span class="annottext">IoSubSystem -&gt; IO a
</span><a href="#local-6989586621679540210"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IoSubSystem -&gt; IO a
</span><a href="#local-6989586621679540210"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">IoSubSystem
</span><a href="GHC.IO.SubSystem.html#ioSubSystem"><span class="hs-identifier hs-var">ioSubSystem</span></a></span><span>
</span><span id="line-72"></span><span>
</span><span id="line-73"></span><span id="local-6989586621679540232"><span class="annot"><a href="GHC.IO.SubSystem.html#withIoSubSystem%27"><span class="hs-identifier hs-type">withIoSubSystem'</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.RTS.Flags.html#IoSubSystem"><span class="hs-identifier hs-type">IoSubSystem</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679540232"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679540232"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-74"></span><span id="withIoSubSystem%27"><span class="annot"><span class="annottext">withIoSubSystem' :: forall a. (IoSubSystem -&gt; a) -&gt; a
</span><a href="GHC.IO.SubSystem.html#withIoSubSystem%27"><span class="hs-identifier hs-var hs-var">withIoSubSystem'</span></a></span></span><span> </span><span id="local-6989586621679540209"><span class="annot"><span class="annottext">IoSubSystem -&gt; a
</span><a href="#local-6989586621679540209"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IoSubSystem -&gt; a
</span><a href="#local-6989586621679540209"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">IoSubSystem
</span><a href="GHC.IO.SubSystem.html#ioSubSystem"><span class="hs-identifier hs-var">ioSubSystem</span></a></span><span>
</span><span id="line-75"></span><span>
</span><span id="line-76"></span><span class="annot"><a href="GHC.IO.SubSystem.html#whenIoSubSystem"><span class="hs-identifier hs-type">whenIoSubSystem</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.RTS.Flags.html#IoSubSystem"><span class="hs-identifier hs-type">IoSubSystem</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-77"></span><span id="whenIoSubSystem"><span class="annot"><span class="annottext">whenIoSubSystem :: IoSubSystem -&gt; IO () -&gt; IO ()
</span><a href="GHC.IO.SubSystem.html#whenIoSubSystem"><span class="hs-identifier hs-var hs-var">whenIoSubSystem</span></a></span></span><span> </span><span id="local-6989586621679540208"><span class="annot"><span class="annottext">IoSubSystem
</span><a href="#local-6989586621679540208"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span id="local-6989586621679540207"><span class="annot"><span class="annottext">IO ()
</span><a href="#local-6989586621679540207"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679540206"><span class="annot"><span class="annottext">sub :: IoSubSystem
</span><a href="#local-6989586621679540206"><span class="hs-identifier hs-var hs-var">sub</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IoSubSystem
</span><a href="GHC.IO.SubSystem.html#ioSubSystem"><span class="hs-identifier hs-var">ioSubSystem</span></a></span><span>
</span><span id="line-78"></span><span>                         </span><span class="annot"><span class="annottext">Bool -&gt; IO () -&gt; IO ()
forall (f :: * -&gt; *). Applicative f =&gt; Bool -&gt; f () -&gt; f ()
</span><a href="GHC.Base.html#when"><span class="hs-identifier hs-var">when</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IoSubSystem
</span><a href="#local-6989586621679540206"><span class="hs-identifier hs-var">sub</span></a></span><span> </span><span class="annot"><span class="annottext">IoSubSystem -&gt; IoSubSystem -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3D%3D"><span class="hs-operator hs-var">==</span></a></span><span> </span><span class="annot"><span class="annottext">IoSubSystem
</span><a href="#local-6989586621679540208"><span class="hs-identifier hs-var">m</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">IO ()
</span><a href="#local-6989586621679540207"><span class="hs-identifier hs-var">f</span></a></span><span>
</span><span id="line-79"></span><span>
</span><span id="line-80"></span></pre></body></html>